home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / bor_ti.exe / TI1035.ASC < prev    next >
Text File  |  1992-10-23  |  13KB  |  397 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Borland C++                           NUMBER  :  1035
  9.   VERSION  :  3.1
  10.        OS  :  ALL
  11.      DATE  :  October 23, 1992                         PAGE  :  1/6
  12.  
  13.     TITLE  :  Using the Template version of the Class Library.
  14.  
  15.  
  16.  
  17.  
  18.  
  19.   This document provides an overview of the various causes of the
  20.   the "Illegal Structure Operation..." error message generated when
  21.   using template classes, template functions, and/or BIDS.
  22.  
  23.  
  24.   Consider the classic function template max():
  25.  
  26.          template <class T>
  27.          T max(T x, T y)
  28.          {
  29.             return (x > y) ? x : y ;
  30.          }
  31.  
  32.  
  33.   In order to pass in a user-defined type into this function, say
  34.   for instance class Foo{...};, Foo would need to have an
  35.   appropriate overloaded operator >() defined. If Foo did not have
  36.   such a function, passing in Foo objects would cause illegal or
  37.   undefined behavior because there is no comparison mechanism
  38.   for the compiler to use for Foo types. The same rules apply when
  39.   using the BIDS class library.
  40.  
  41.  
  42.   If you are using the template-based BIDS library, you'll see
  43.   advertised in the manuals that the template-based containers can
  44.   contain ANY type of object, default or user-defined, not just
  45.   those derived from the Object class (which is the requirement for
  46.   using the non-template base container classes).  This is true,
  47.   although there are requirements for user-defined types which are
  48.   not clearly defined in the documentation.  If these requirements
  49.   are not met, you will see compiler error messages such as "
  50.   Illegal structure operation in Base<T>::find<T> " or " Illegal
  51.   structure operation in Base<T>::findPred<T> ".
  52.  
  53.  
  54.   The following table illustrates what operators and functions need
  55.   to be provided for your type according to which BIDS container
  56.   you use.  For example, in order to store a user-defined class in
  57.   BI_BagAsVector<foo>, foo must have operator==( ) defined
  58.  
  59.  
  60.   ---------------------------------------------------------------- +
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Borland C++                           NUMBER  :  1035
  75.   VERSION  :  3.1
  76.        OS  :  ALL
  77.      DATE  :  October 23, 1992                         PAGE  :  2/6
  78.  
  79.     TITLE  :  Using the Template version of the Class Library.
  80.  
  81.  
  82.  
  83.  
  84.                          |    |    |   |            |  Constructor |
  85.   BIDS                   | == | != | < | isSortable |Default| Copy |
  86.   -----------------------|----|----|---|------------|-------|------|
  87.   BI_VectorImp           |    |    |   |            |       |      |
  88.   -----------------------|----|----|---|------------|-------|------|
  89.   BI_CVectorImp          |    |    |   |            |       |      |
  90.   -----------------------|----|----|---|------------|-------|------|
  91.   BI_SVectorImp          | X  |    | X |            |  X    |   X  |
  92.   -----------------------|----|----|---|------------|-------|------|
  93.   BI_IVectorImp          |    |    |   |            |       |      |
  94.   -----------------------|----|----|---|------------|-------|------|
  95.   BI_ICVectorImp         | X  |    |   |      X     |       |      |
  96.   -----------------------|----|----|---|------------|-------|------|
  97.   BI_ISVectorImp         | X  |    | X |      X     |       |      |
  98.   -----------------------|----|----|---|------------|-------|------|
  99.                          |    |    |   |            |       |      |
  100.   -----------------------|----|----|---|------------|-------|------|
  101.   BI_ListImp             | X  |    |   |            |       |   X  |
  102.   -----------------------|----|----|---|------------|-------|------|
  103.   BI_SListImp            | X  |  X | X |            |   X   |   X  |
  104.   -----------------------|----|----|---|------------|-------|------|
  105.   BI_IListImp            | X  |    |   |            |       |      |
  106.   -----------------------|----|----|---|------------|-------|------|
  107.   BI_ISListImp           | X  |  X | X |            |   X   |   X  |
  108.   -----------------------|----|----|---|------------|-------|------|
  109.                          |    |    |   |            |       |      |
  110.   -----------------------|----|----|---|------------|-------|------|
  111.   BI_DoubleListImp       | X  |    |   |            |       |      |
  112.   -----------------------|----|----|---|------------|-------|------|
  113.   BI_SDoubleListImp      | X  |  X | X |            |   X   |   X  |
  114.   -----------------------|----|----|---|------------|-------|------|
  115.   BI_IDoubleListImp      | X  |    |   |            |       |      |
  116.   -----------------------|----|----|---|------------|-------|------|
  117.   BI_ISDoubleListImp     | X  |  X | X |            |   X   |   X  |
  118.   -----------------------|----|----|---|------------|-------|------|
  119.                          |    |    |   |            |       |      |
  120.   -----------------------|----|----|---|------------|-------|------|
  121.   BI_ArrayAsVectorImp    |    |    |   |            |   X   |   X  |
  122.   -----------------------|----|----|---|------------|-------|------|
  123.   BI_ArrayAsVector       | X  |    |   |            |   X   |   X  |
  124.   -----------------------|----|----|---|------------|-------|------|
  125.   BI_SArrayAsVector      | X  |    | X |      X     |   X   |   X  |
  126.   -----------------------|----|----|---|------------|-------|------|
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Borland C++                           NUMBER  :  1035
  141.   VERSION  :  3.1
  142.        OS  :  ALL
  143.      DATE  :  October 23, 1992                         PAGE  :  3/6
  144.  
  145.     TITLE  :  Using the Template version of the Class Library.
  146.  
  147.  
  148.  
  149.  
  150.   BI_IArrayAsVector      | X  |    |   |      X     |       |      |
  151.   -----------------------|----|----|---|------------|-------|------|
  152.   BI_ISArrayAsVector     | X  |    | X |      X     |       |      |
  153.   -----------------------|----|----|---|------------|-------|------|
  154.                          |    |    |   |            |       |      |
  155.   -----------------------|----|----|---|------------|-------|------|
  156.   BI_StackAsVectorImp    |    |    |   |            |   X   |   X  |
  157.   -----------------------|----|----|---|------------|-------|------|
  158.   BI_StackAsVector       | X  |    |   |            |   X   |   X  |
  159.   -----------------------|----|----|---|------------|-------|------|
  160.   BI_IStackAsVector      | X  |    |   |            |   X   |      |
  161.   -----------------------|----|----|---|------------|-------|------|
  162.   BI_StackAsListImp      |    |    |   |            |   X   |   X  |
  163.   -----------------------|----|----|---|------------|-------|------|
  164.   BI_StackAsList         |    |    |   |            |   X   |   X  |
  165.   -----------------------|----|----|---|------------|-------|------|
  166.   BI_IStackAsList        | X  |    |   |            |   X   |      |
  167.   -----------------------|----|----|---|------------|-------|------|
  168.                          |    |    |   |            |       |      |
  169.   -----------------------|----|----|---|------------|-------|------|
  170.   BI_DequeAsVectorImp    |    |    |   |            |   X   |   X  |
  171.   -----------------------|----|----|---|------------|-------|------|
  172.   BI_DequeAsVector       |    |    |   |            |   X   |   X  |
  173.   -----------------------|----|----|---|------------|-------|------|
  174.   BI_IDequeAsVector      | X  |  X |   |            |   X   |      |
  175.   -----------------------|----|----|---|------------|-------|------|
  176.   BI_DequeAsDoubleListImp|    |    |   |            |   X   |   X  |
  177.   -----------------------|----|----|---|------------|-------|------|
  178.   BI_DequeAsDoubleList   | X  |  X |   |            |   X   |   X  |
  179.   -----------------------|----|----|---|------------|-------|------|
  180.   BI_IDequeAsDoubleList  |    |    |   |            |       |      |
  181.   -----------------------|----|----|---|------------|-------|------|
  182.                          |    |    |   |            |       |      |
  183.   -----------------------|----|----|---|------------|-------|------|
  184.   BI_QueueAsVector       |    |    |   |            |   X   |   X  |
  185.   -----------------------|----|----|---|------------|-------|------|
  186.   BI_IQueueAsVector      |    |    |   |            |